package com.zdb.personal.controller;


import com.zdb.personal.po.ZdbPmsAddressPo;
import com.zdb.personal.service.ZdbPmsAddressService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/address")
public class ZdbPmsAddressController {

    @Resource
    private ZdbPmsAddressService zdbPmsAddressService;


    /**
     * 根据id查询所有收货地址
     * @param uid userID
     * @return
     */
    @RequestMapping("/queryAddress/{uid}")
    public List<ZdbPmsAddressPo> queryAddress(@PathVariable("uid") int uid){
        HashMap<String, Object> map = new HashMap<>();
        map.put("uid",uid);
        return this.zdbPmsAddressService.listByMap(map);
    }


    /**
     * 修改地址
     * @param zdbPmsAddress 必须带有id的实体
     * @return 是否修改成功
     */
    @RequestMapping("/updataAddress")
    public boolean updataAddress(@RequestBody ZdbPmsAddressPo zdbPmsAddress){
        System.err.println(zdbPmsAddress);
        return this.zdbPmsAddressService.updateById(zdbPmsAddress);
    }


}
